package com.example.demo.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import com.example.demo.dto.SearchInfo;
import com.example.demo.entity.Department;



@Repository()
public interface Department_Mapper extends BaseMapper<Department>{
	
	@Select("select department.*,doctor.name doctor_name "
			+ " from department inner join doctor on department.doctor_id=doctor.id   ${where} ${limitstr}")
	public List<Department> select(SearchInfo info);
	@Select("select count(1) from department inner join doctor on department.doctor_id=doctor.id   ${where} ")
	public long selectCount(SearchInfo info);
	
	@Insert("insert into department (name,description,doctor_id) values(#{name},#{description},#{doctor_id})")
	public void insert (Department d);
	
	@Update("update department set name=#{name},description=#{description},doctor_id=#{doctor_id} where id=#{id}")
	public void update (Department d);
	
	
	@Select("delete from department where id=#{id}")
	public void delete(int id);
	
	@Select("select * from department where id=#{id} ")
	public Department selectById(int id);
	
}
